import axios from 'axios';
import { Indicator } from 'mint-ui';
// import store from '../store/index';

// 默认配置
axios.defaults.baseURL = 'http://www.sinya.online/api/';

// http request 拦截器
axios.interceptors.request.use(
  config => {
    Indicator.open({
      text: '加载中...',
      spinnerType: 'fading-circle'
    });
    return config;
  },
  err => Promise.reject(err),
);

// http response 拦截器
axios.interceptors.response.use(
  response => {
    Indicator.close();
    return response;
  },
  (error) => {
    if (error.response) {
      switch (error.response.status) {
        case 401:
          break;
        default:
          break;
      }
    }
    return Promise.reject(error);
  },
);

export default config => axios(config);

